<?php
/**
 * Created by PhpStorm.
 * User: yshang15
 * Date: 16/4/30
 * Time: 上午11:29
 */

namespace frontend\controllers\bazi;

class JiaziController extends \yii\web\Controller
{
    public $jiazi = array(
        1 => array('year' => '1924,1984', 'jiazi' => '甲子'),
        2 => array('year' => '1925,1985', 'jiazi' => '乙丑'),
        3 => array('year' => '1926,1986', 'jiazi' => '丙寅'),
        4 => array('year' => '1927,1987', 'jiazi' => '丁卯'),
        5 => array('year' => '1928,1988', 'jiazi' => '戊辰'),
        6 => array('year' => '1929,1989', 'jiazi' => '己巳'),
        7 => array('year' => '1930,1990', 'jiazi' => '庚午'),
        8 => array('year' => '1931,1991', 'jiazi' => '辛未'),
        9 => array('year' => '1932,1992', 'jiazi' => '壬申'),
        10 => array('year' => '1933,1993', 'jiazi' => '癸酉'),
        11 => array('year' => '1934,1994', 'jiazi' => '甲戌'),
        12 => array('year' => '1935,1995', 'jiazi' => '乙亥'),
        13 => array('year' => '1936,1996', 'jiazi' => '丙子'),
        14 => array('year' => '1937,1997', 'jiazi' => '丁丑'),
        15 => array('year' => '1938,1998', 'jiazi' => '戊寅'),
        16 => array('year' => '1939,1999', 'jiazi' => '己卯'),
        17 => array('year' => '1940,2000', 'jiazi' => '庚辰'),
        18 => array('year' => '1941,2001', 'jiazi' => '辛巳'),
        19 => array('year' => '1942,2002', 'jiazi' => '壬午'),
        20 => array('year' => '1943,2003', 'jiazi' => '癸未'),
        21 => array('year' => '1944,2004', 'jiazi' => '甲申'),
        22 => array('year' => '1945,2005', 'jiazi' => '乙酉'),
        23 => array('year' => '1946,2006', 'jiazi' => '丙戌'),
        24 => array('year' => '1947,2007', 'jiazi' => '丁亥'),
        25 => array('year' => '1948,2008', 'jiazi' => '戊子'),
        26 => array('year' => '1949,2009', 'jiazi' => '己丑'),
        27 => array('year' => '1950,2010', 'jiazi' => '庚寅'),
        28 => array('year' => '1951,2011', 'jiazi' => '辛卯'),
        29 => array('year' => '1952,2012', 'jiazi' => '壬辰'),
        30 => array('year' => '1953,2013', 'jiazi' => '癸巳'),
        31 => array('year' => '1954,2014', 'jiazi' => '甲午'),
        32 => array('year' => '1955,2015', 'jiazi' => '乙未'),
        33 => array('year' => '1956,2016', 'jiazi' => '丙申'),
        34 => array('year' => '1957,2017', 'jiazi' => '丁酉'),
        35 => array('year' => '1958,2018', 'jiazi' => '戊戌'),
        36 => array('year' => '1959,2019', 'jiazi' => '己亥'),
        37 => array('year' => '1960,2020', 'jiazi' => '庚子'),
        38 => array('year' => '1961,2021', 'jiazi' => '辛丑'),
        39 => array('year' => '1962,2022', 'jiazi' => '壬寅'),
        40 => array('year' => '1963,2023', 'jiazi' => '癸卯'),
        41 => array('year' => '1964,2024', 'jiazi' => '甲辰'),
        42 => array('year' => '1965,2025', 'jiazi' => '乙巳'),
        43 => array('year' => '1966,2026', 'jiazi' => '丙午'),
        44 => array('year' => '1967,2027', 'jiazi' => '丁未'),
        45 => array('year' => '1968,2028', 'jiazi' => '戊申'),
        46 => array('year' => '1969,2029', 'jiazi' => '己酉'),
        47 => array('year' => '1970,2030', 'jiazi' => '庚戌'),
        48 => array('year' => '1971,2031', 'jiazi' => '辛亥'),
        49 => array('year' => '1972,2032', 'jiazi' => '壬子'),
        50 => array('year' => '1973,2033', 'jiazi' => '癸丑'),
        51 => array('year' => '1974,2034', 'jiazi' => '甲寅'),
        52 => array('year' => '1975,2035', 'jiazi' => '乙卯'),
        53 => array('year' => '1976,2036', 'jiazi' => '丙辰'),
        54 => array('year' => '1977,2037', 'jiazi' => '丁巳'),
        55 => array('year' => '1978,2038', 'jiazi' => '戊午'),
        56 => array('year' => '1979,2039', 'jiazi' => '乙未'),
        57 => array('year' => '1980,2040', 'jiazi' => '庚申'),
        58 => array('year' => '1981,2041', 'jiazi' => '辛酉'),
        59 => array('year' => '1982,2042', 'jiazi' => '壬戌'),
        60 => array('year' => '1983,2043', 'jiazi' => '癸亥'),
    );

    public function actionIndex()
    {
        $location = array();
        $location[] = rand(1, 6);
        $location[] = rand(7, 12);
        $location[] = rand(13, 18);
        $location[] = rand(19, 24);
        $location[] = rand(25, 30);
        $location[] = rand(31, 36);
        $location[] = rand(37, 42);
        $location[] = rand(43, 48);
        $location[] = rand(49, 60);

        return $this->render('index', array('tiangan' => $this->jiazi, 'location' => $location));
    }

    public function actionYear()
    {
        $location = array();
        $location[] = rand(1, 6);
        $location[] = rand(7, 12);
        $location[] = rand(13, 18);
        $location[] = rand(19, 24);
        $location[] = rand(25, 30);
        $location[] = rand(31, 36);
        $location[] = rand(37, 42);
        $location[] = rand(43, 48);
        $location[] = rand(49, 60);

        return $this->render('year', array('tiangan' => $this->jiazi, 'location' => $location));
    }

}